package cn.org.timespace.easyframe.dao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import cn.org.timespace.easyframe.util.pager.Pager;

/**
 * <p>
 * easyframe框架DAO父类
 * </p>
 *
 * @version 1.0, 11/01/18
 * @since 1.0
 * @author 
 */

public class EfBaseDAO extends HibernateDaoSupport {
	
	public static Log log = LogFactory.getLog(EfBaseDAO.class);
	
//	public EfBaseDAO(String baseDaoInstance){ 
//			log = LogFactory.getLog(baseDaoInstance);
//	}
	
	protected void setQueryPager(Query query,Pager p){
		query.setFirstResult((p.getCurrentPageNum() - 1)*p.getItemPerPage());
		query.setMaxResults(p.getItemPerPage());		
	}
	
	protected void closeSessionAndQuery(Session session,Query query){
		if(session != null) session.close();
		if(query != null) query = null;	
	}
	
}
